model_selection = c("adult_vision", "adult_vision_sound", "baseline", "matching")
df.fits = df.choices %>%
mutate(answer = factor(answer, levels = 1:3)) %>%
left_join(df.predictions %>%
select(world, answer, all_of(model_selection)),
by = c("world", "answer")) %>%
mutate(across(all_of(model_selection), ~ ifelse(. == 0, 0.01, .))) %>%
group_by(age, participant) %>%
summarize(across(all_of(model_selection), ~ exp(sum(log(.))))) %>%
ungroup() %>%
rowwise() %>%
mutate(sum = sum(c_across(all_of(model_selection))),
across(all_of(model_selection), ~ . / sum)) %>%
select(-sum)model_selection = c("adult_vision", "adult_vision_sound", "baseline", "matching")
df.fits.adults = df.adults %>%
mutate(answer = as.factor(answer)) %>%
filter(world %in% unique(df.choices$world)) %>%
left_join(df.predictions %>%
select(world, answer, all_of(model_selection)),
by = c("world", "answer")) %>%
mutate(across(all_of(model_selection), ~ ifelse(. == 0, 0.01, .))) %>%
group_by(experiment, participant) %>%
summarize(across(all_of(model_selection), ~ exp(sum(log(.))))) %>%
ungroup() %>%
rowwise() %>%
mutate(sum = sum(c_across(all_of(model_selection))),
across(all_of(model_selection), ~ . / sum)) %>%
select(-sum)p1 = func_plot_with_images(data = df.choices %>%
filter(age == 4),
model = df.predictions)
p2 = func_plot_with_images(data = df.choices %>%
filter(age == 5),
model = df.predictions)
p3 = func_plot_with_images(data = df.choices %>%
filter(age == 6),
model = df.predictions)
p4 = func_plot_with_images(data = df.choices %>%
filter(age == 7),
model = df.predictions)
p5 = func_plot_with_images(data = df.choices %>%
filter(age == 8),
model = df.predictions)
p1 + p2 + p3 + p4 + p5 +
plot_layout(ncol = 1,
tag_level = "new") +
plot_annotation(tag_levels = "A")